{extend name="layout/layout" /}

{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="portlet light">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-share font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase"> 编辑台账 </span>
                </div>
                <div class="actions">
                    <a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;" data-original-title="" title=""> </a>
                </div>
            </div>
            <div class="portlet-body">
                <form id="ajax-form" class="form-horizontal" method="post" enctype="multipart/form-data">
                    <div class="form-body">
                        <div class="row" style="margin-bottom: 10px;">
                            <div class="col-md-9">
                                <div class="form-inline">
                                    <label class="control-label col-md-3">
                                        选择乡村
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input class="city" type="hidden" name="cityId" value="{$info.cityId}">
                                        <input class="xian" type="hidden" name="xianId" value="{$info.xianId}">
                                        <input class="town" type="hidden" name="townId" value="{$info.townId}">
                                        <input class="village" type="hidden" name="villageId" value="{$info.villageId}">
                                        <p class="form-control-static"> {$area} </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        台账年度
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6">
                                        <input type="text" class="form-control date-year" name="year" value="{$info.year}" >
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        享受政策
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <div id="policy-group">
                                            {php}$policyList = json_decode($info['policy'], true);{/php}
                                            {foreach name="policyList" item="policys" key="policysKey"}
                                            <div class="policy-div" {if condition="($policysKey > 0)"}style="margin-top: 20px;"{/if}>
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <select class="form-control" name="policyType">
                                                            <option value="0">请选择</option>
                                                            {foreach name="policyTypes" item="policyType" key="policyTypeKey"}
                                                                <option value="{$policyTypeKey}" {if condition="($policys['policyType'] == $policyTypeKey)"}selected="selected"{/if}>{$policyType}</option>
                                                            {/foreach}
                                                        </select>
                                                    </div>
                                                    {if condition="($policysKey > 0)"}
                                                        <div class="col-md-1">
                                                            <button type="button" class="btn btn-danger remove-policy"><i class="fa fa-close"></i></button>
                                                        </div>
                                                    {/if}
                                                </div>
                                                {foreach name="policys.policySpec" item="policySpec" key="policySpecKey"}
                                                    <div class="row policySpec-div" style="margin-top: 10px;">
                                                        <div class="col-md-3">
                                                            <select class="form-control spec-type" name="specType">
                                                                <option value="1" {if condition="($policySpec['specType'] == 1)"}selected="selected"{/if} >分季</option>
                                                                <option value="2" {if condition="($policySpec['specType'] == 2)"}selected="selected"{/if} >分月</option>
                                                                <option value="0" {if condition="($policySpec['specType'] == 0)"}selected="selected"{/if} >无</option>
                                                            </select>
                                                        </div>
                                                        <div class="col-md-3 quarter-div">
                                                            <select class="form-control quarter" name="quarter">
                                                                <option value="1" {if condition="($policySpec['quarter'] == 1)"}selected="selected"{/if} >春季</option>
                                                                <option value="2" {if condition="($policySpec['quarter'] == 2)"}selected="selected"{/if} >夏季</option>
                                                                <option value="3" {if condition="($policySpec['quarter'] == 3)"}selected="selected"{/if} >秋季</option>
                                                                <option value="4" {if condition="($policySpec['quarter'] == 4)"}selected="selected"{/if} >冬季</option>
                                                            </select>
                                                        </div>
                                                        <div class="col-md-3 month-div">
                                                            <select class="form-control month" name="month">
                                                                <option value="1" {if condition="($policySpec['month'] == 1)"}selected="selected"{/if} >1月</option>
                                                                <option value="2" {if condition="($policySpec['month'] == 2)"}selected="selected"{/if}>2月</option>
                                                                <option value="3" {if condition="($policySpec['month'] == 3)"}selected="selected"{/if}>3月</option>
                                                                <option value="4" {if condition="($policySpec['month'] == 4)"}selected="selected"{/if}>4月</option>
                                                                <option value="5" {if condition="($policySpec['month'] == 5)"}selected="selected"{/if}>5月</option>
                                                                <option value="6" {if condition="($policySpec['month'] == 6)"}selected="selected"{/if}>6月</option>
                                                                <option value="7" {if condition="($policySpec['month'] == 7)"}selected="selected"{/if}>7月</option>
                                                                <option value="8" {if condition="($policySpec['month'] == 8)"}selected="selected"{/if}>8月</option>
                                                                <option value="9" {if condition="($policySpec['month'] == 9)"}selected="selected"{/if}>9月</option>
                                                                <option value="10" {if condition="($policySpec['month'] == 10)"}selected="selected"{/if}>10月</option>
                                                                <option value="11" {if condition="($policySpec['month'] == 11)"}selected="selected"{/if}>11月</option>
                                                                <option value="12" {if condition="($policySpec['month'] == 12)"}selected="selected"{/if}>12月</option>
                                                            </select>
                                                        </div>
                                                        <div class="col-md-3 explain-div">
                                                            <select class="form-control explain" name="explain">
                                                                <option value="1" {if condition="($policySpec['explain'] == 1)"}selected="selected"{/if}>金额补助</option>
                                                                <option value="2" {if condition="($policySpec['explain'] == 2)"}selected="selected"{/if}>其他说明</option>
                                                            </select>
                                                        </div>
                                                        <div class="col-md-1">
                                                            {if condition="($policySpecKey > 0)"}
                                                                <button type="button" class="btn btn-danger removePolicySpec-btn"><i class="fa fa-minus"></i></button>
                                                            {else /}
                                                                <button type="button" class="btn btn-success addPolicySpec-btn"><i class="fa fa-plus"></i></button>
                                                            {/if}
                                                        </div>
                                                    </div>
                                                {/foreach}
                                            </div>
                                            {/foreach}
                                            {empty name="policyList"}
                                            <div class="policy-div">
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <select class="form-control" name="policyType">
                                                            <option value="0">请选择</option>
                                                            {foreach name="policyList" item="policy" key="policykey"}
                                                            <option value="{$policykey}">{$policy}</option>
                                                            {/foreach}
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="row policySpec-div" style="margin-top: 10px;">
                                                    <div class="col-md-3">
                                                        <select class="form-control spec-type" name="specType">
                                                            <option value="1">分季</option>
                                                            <option value="2">分月</option>
                                                            <option value="0">无</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-md-3 quarter-div">
                                                        <select class="form-control quarter" name="quarter">
                                                            <option value="1">春季</option>
                                                            <option value="2">夏季</option>
                                                            <option value="3">秋季</option>
                                                            <option value="4">冬季</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-md-3 month-div hide">
                                                        <select class="form-control month" name="month">
                                                            <option value="1">1月</option>
                                                            <option value="2">2月</option>
                                                            <option value="3">3月</option>
                                                            <option value="4">4月</option>
                                                            <option value="5">5月</option>
                                                            <option value="6">6月</option>
                                                            <option value="7">7月</option>
                                                            <option value="8">8月</option>
                                                            <option value="9">9月</option>
                                                            <option value="10">10月</option>
                                                            <option value="11">11月</option>
                                                            <option value="12">12月</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-md-3">
                                                        <select class="form-control explain" name="explain">
                                                            <option value="1">金额补助</option>
                                                            <option value="2">其他说明</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-md-1">
                                                        <button type="button" class="btn btn-success addPolicySpec-btn"><i class="fa fa-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                            {/empty}
                                        </div>

                                        <button type="button" class="btn btn-success addPolicy-btn" style="margin-top: 10px;">
                                            <i class="fa fa-plus"></i> 添加享受政策
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        备注说明
                                    </label>
                                    <div class="col-md-9">
                                        <div class="mt-radio-inline">
                                            <label class="mt-radio mt-radio-outline">
                                                <input type="radio" class="" name="isRemark" value="1" {if condition="($info['isRemark'] == 1)"}checked="checked"{/if} >
                                                需要
                                                <span></span>
                                            </label>
                                            <label class="mt-radio mt-radio-outline">
                                                <input type="radio" class="" name="isRemark" value="2" {if condition="($info['isRemark'] == 2)"}checked="checked"{/if} >
                                                不需要
                                                <span></span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="id" value="{$info.id}">

                        <hr />
                        <div class="row">
                            <div class="form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="button" id="form-submit" class="btn blue save-btn">
                                        保存 <i class="fa fa-floppy-o"></i>
                                    </button>
                                    <button type="button" class="btn default" onclick="history.go(-1);">
                                        返回 <i class="fa fa-mail-forward"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/pages/js/povertypolicyledger.js" type="text/javascript"></script>
{/block}